﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace vidu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.ShowNewFolderButton = false;
            fbd.Description = "Vui lòng chọn thư mục:";

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                listView1.SmallImageList = imageList1;      
                string[] filePath = Directory.GetFiles(fbd.SelectedPath, "*.doc", SearchOption.AllDirectories);
                
                foreach (string s in filePath)
                {
                    if ((Path.GetExtension(s) == ".doc") || (Path.GetExtension(s) == ".docx"))
                    {
                        string fileName = s.Substring(s.LastIndexOf("\\") + 1);
                        ListViewItem lwItem = new ListViewItem(fileName, 0);
                        if (fileName[fileName.Length - 1] == 'x')
                            lwItem.ImageIndex = 1;
                        else lwItem.ImageIndex = 0;
                        listView1.Items.Add(lwItem);
                    }
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}
